<?php
date_default_timezone_set("PRC");
require($_SERVER['DOCUMENT_ROOT']."/admin/public/header.php");
require($_SERVER['DOCUMENT_ROOT']."/public/func.php");
$config=require($_SERVER['DOCUMENT_ROOT']."/public/config.php");
$keywords=empty($_POST['keywords'])?'':$keywords=$_POST['keywords'];
$where=empty($_POST['cid'])?('where `tags`like'.'"%'.$keywords.'%"'):('where `cid`='.$_POST['cid'].' && `tags` like "%'.$keywords.'%"');
$arr=select($config,'article',$where);
$crr=selects($config,'classify','');
?>
<meta charset="UTF-8">
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/admin/public/index.php">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">文章管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                 <form action="" method="post">
                       <table class="search-tab">
                       <tr>
                       <th width="120">选择分类:</th>
                       <td>
                       <select name="cid" id="">
                       <option value="">全部</option>
                      <?php 
                      foreach ($crr as  $v) {
                           echo '<option value='.$v['id'].'>'.$v['cname'].'</option>';
                                }
                       ?>
                            </select>
                            </td>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="insert.php"><i class="icon-font"></i>新增作品</a>
                        <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量删除</a>
                        <a id="updateOrd" href="javascript:void(0)"><i class="icon-font"></i>更新排序</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>ID</th>
                            <th>关联用户id</th>
                            <th>关联分类id</th>
                            <th>标题</th>
                            <th>作者</th>
                            <th>内容</th>
                            <th>文件</th>
                            <th>标签</th>
                            <th>状态</th>
                            <th>更新时间</th>
                            <th>操作</th>
                        </tr>
<?php
                           foreach ($arr as $k => $v) {
            
                echo       '<tr>
                            <td>'.$v['id'].'</td>
                            <td>'.$v['uid'].'</td>
                            <td>'.$v['cid'].'</td>
                            <td>'.$v['title'].'</td>
                            <td>'.$v['autor'].'</td>
                            <td>'.mb_substr($v['content'],0,20,'utf-8').'</td>
                            <td>'.mb_substr($v['mfile'],0,20,'utf-8').'</td>
                            <td>'.$v['tags'].'</td>
                            <td>'.($v['status']?'显示':'不显示').'</td>
                            <td>'.date('Y-m-d H:i:s',$v['ctime']).'</td>
                            <td>
                                <a class="link-update" href="xianshi.php?id='.$v['id'].'">修改</a>
                                <a class="link-del" href="delete.php?id='.$v['id'].'">删除</a>
                            </td>
                        </tr>';
                    }?> 
                    </table>
                    <div class="list-page">
                        第<?php echo $_SESSION['p'] ?>页</a>&nbsp;
                        <a href="/admin/article/design.php?p=<?php echo $_SESSION['first']?>">首页</a>&nbsp;
                        <a href="/admin/article/design.php?p=<?php echo $_SESSION['prev']?>">上一页</a>&nbsp;
                        <a href="/admin/article/design.php?p=<?php echo $_SESSION['next']?>">下一页</a>&nbsp;
                        <a href="/admin/article/design.php?p=<?php echo $_SESSION['countpage']?>">尾页</a>&nbsp;
                        共<?php echo $_SESSION['countpage']?>页
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
<?php
require($_SERVER['DOCUMENT_ROOT']."/admin/public/tali.php");
?>